//社区通用js

//个人中心页面
function goPersonal(memberId){
    window.location.href = "/sunday/weixin/community/personal/index?memberId="+memberId;
}

//详情页面
function goDetail(id,memberId){
    window.location.href = "/sunday/weixin/community/detail?id="+id+"&memberId="+memberId;
}

//关注
function goFollow(type,otherId,memberId) {
    $.ajax({
        type : "post",
        url : "/sunday/weixin/collection/save",
        data:{"type":type,"otherId":otherId,"memberId":memberId},
        async : false,
        success : function(data){
            //关闭加载
            if(data.code == 0){
                layer.msg('关注成功', {
                    icon: 1
                });
                window.setTimeout(function(){
                    location.reload();
                },1000);
            }else{
                layer.msg(data.message, {
                    icon: 2
                });
            }
        }
    });
}

//点赞
function goPraise(mainId,className,memberId){
    $.ajax({
        type : "post",
        url : "/sunday/weixin/community/goPraise",
        data:{"mainId":mainId,"className":className,"memberId":memberId},
        async : false,
        success : function(data){
            //关闭加载
            if(data.code == 0){
                $("#point"+mainId).text(data.result);
                var praiseDiv = document.getElementById("praiseDiv"+mainId);
                var className = praiseDiv.getAttribute("class");
                if(className == "fabulous"){
                    praiseDiv.setAttribute("class","fabulous on");
                }else{
                    praiseDiv.setAttribute("class","fabulous");
                }
            }else{
                layer.msg(data.message, {
                    icon: 2
                });
            }
        }
    });
}